Skip to content

Commit

Permalink
Add SDK for IAM v1 API. (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
linouk23 authored Jan 27, 2022
1 parent 56a8a67 commit 39f8820
Show file tree
Hide file tree
Showing 14 changed files with 2,625 additions and 0 deletions.
129 changes: 129 additions & 0 deletions iam/v1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Go API client for v1

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.

- API version: 0.0.1-alpha0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen

## Installation

Install the following dependencies:

```shell
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
```

Put the package under your project folder and add the following in import:

```golang
import sw "./v1"
```

To use a proxy, set the environment variable `HTTP_PROXY`:

```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```

## Configuration of Server URL

Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.

### Select Server Configuration

For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.

```golang
ctx := context.WithValue(context.Background(), sw.ContextServerIndex, 1)
```

### Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.

```golang
ctx := context.WithValue(context.Background(), sw.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```

Note, enum values are always validated and all unused variables are silently ignored.

### URLs Configuration per Operation

Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.

```
ctx := context.WithValue(context.Background(), sw.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), sw.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```

## Documentation for API Endpoints

All URIs are relative to *https://api.confluent.cloud*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*ServiceAccountsV1Api* | [**ListV1ServiceAccounts**](docs/ServiceAccountsV1Api.md#listv1serviceaccounts) | **Get** /service_accounts | List of Service Accounts


## Documentation For Models

- [Error](docs/Error.md)
- [V1ServiceAccount](docs/V1ServiceAccount.md)
- [V1ServiceAccountList](docs/V1ServiceAccountList.md)


## Documentation For Authorization



### api-key

- **Type**: HTTP basic authentication

Example

```golang
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
```


## Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:

* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`

## Author



246 changes: 246 additions & 0 deletions iam/v1/api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
openapi: 3.0.0
info:
title: IAM API v1
version: 0.0.1-alpha0
x-api-id: 3bd28786-25ed-4da8-b44f-7ecd12e7e740
x-api-group: v1
servers:
- description: Confluent Cloud production
url: https://api.confluent.cloud
paths:
/service_accounts:
get:
description: Retrieve a sorted, filtered, paginated list of all service accounts.
operationId: listV1ServiceAccounts
responses:
"200":
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/v1.ServiceAccountList'
description: Service Account.
"400":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Bad Request
"401":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The request lacks valid authentication credentials for this
resource.
"403":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The access credentials were considered insufficient to grant
access
"429":
description: Rate Limit Exceeded
"500":
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Oops, something went wrong!
security:
- api-key: []
summary: List of Service Accounts
tags:
- Service Accounts (v1)
x-codeSamples:
- lang: Shell
source: |-
curl --request GET \
--url https://api.confluent.cloud/service_accounts \
--header 'Authorization: Basic REPLACE_BASIC_AUTH'
- lang: Java
source: |-
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.confluent.cloud/service_accounts")
.get()
.addHeader("Authorization", "Basic REPLACE_BASIC_AUTH")
.build();
Response response = client.newCall(request).execute();
- lang: Go
source: "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\
\n)\n\nfunc main() {\n\n\turl := \"https://api.confluent.cloud/service_accounts\"\
\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"\
Authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\
\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\t\
fmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
- lang: Python
source: |-
import http.client
conn = http.client.HTTPSConnection("api.confluent.cloud")
headers = { 'Authorization': "Basic REPLACE_BASIC_AUTH" }
conn.request("GET", "/service_accounts", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
- lang: Node
source: |-
const http = require("https");
const options = {
"method": "GET",
"hostname": "api.confluent.cloud",
"port": null,
"path": "/service_accounts",
"headers": {
"Authorization": "Basic REPLACE_BASIC_AUTH"
}
};
const req = http.request(options, function (res) {
const chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
const body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
- lang: C
source: |-
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.confluent.cloud/service_accounts");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Basic REPLACE_BASIC_AUTH");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
CURLcode ret = curl_easy_perform(hnd);
- lang: C#
source: |-
var client = new RestClient("https://api.confluent.cloud/service_accounts");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Basic REPLACE_BASIC_AUTH");
IRestResponse response = client.Execute(request);
components:
responses:
BadRequestError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Bad Request
UnauthenticatedError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The request lacks valid authentication credentials for this resource.
OverQuotaError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The request would exceed one or more quotas.
UnauthorizedError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The access credentials were considered insufficient to grant access
ConflictError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: The request is in conflict with the current server state
NotFoundError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Not Found
RateLimitError:
description: Rate Limit Exceeded
DefaultSystemError:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Oops, something went wrong!
schemas:
v1.ServiceAccount:
description: |-
`ServiceAccount` objects are typically used to represent applications and other non-human principals
that may access your Confluent resources.
The API allows you to list all your service accounts.
## The Service Accounts Model
<SchemaDefinition schemaRef="#/components/schemas/v1.ServiceAccount" />
properties:
id:
type: integer
resource_id:
example: sa-12345
type: string
type: object
v1.ServiceAccountList:
description: |-
`ServiceAccount` objects are typically used to represent applications and other non-human principals
that may access your Confluent resources.
The API allows you to list all your service accounts.
## The Service Accounts Model
<SchemaDefinition schemaRef="#/components/schemas/v1.ServiceAccount" />
properties:
users:
description: A data property that contains an array of resource items. Each
entry in the array is a separate resource.
items:
allOf:
- $ref: '#/components/schemas/v1.ServiceAccount'
- required:
- id
type: object
type: array
uniqueItems: true
required:
- users
type: object
Error:
description: Describes a particular error encountered while performing an operation.
properties:
code:
description: An application-specific error code, expressed as a string value.
type: string
message:
description: A short, human-readable summary of the problem. It **SHOULD
NOT** change from occurrence to occurrence of the problem, except for
purposes of localization.
type: string
type: object
securitySchemes:
api-key:
description: Authenticate with API Keys using HTTP Basic Auth. Treat the API
Key ID as the username and API Key Secret as the password.
scheme: basic
type: http
Loading

0 comments on commit 39f8820

Please sign in to comment.