mcc-sdk-go

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MIT

README

Go API client for mccsdk

Introduction

MACH composer Cloud is a platform and API to facilitate and coordinate work across teams that build composable architectures using MACH technology.

All operations available in MACH composer cloud are available through this API. For more information about using it in your MACH architecture, have a look at the documentation website.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.1.0
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://docs.machcomposer.io/

Installation

Install the following dependencies:

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:

import mccsdk "github.com/GIT_USER_ID/GIT_REPO_ID"

To use a proxy, set the environment variable HTTP_PROXY:

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 mccsdk.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), mccsdk.ContextServerIndex, 1)
Templated Server URL

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

ctx := context.WithValue(context.Background(), mccsdk.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 mccsdk.ContextOperationServerIndices and mccsdk.ContextOperationServerVariables context maps.

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

Documentation for API Endpoints

All URIs are relative to https://api.mach.cloud

Class Method HTTP request Description
APIClientsApi ApiClientCreate Post /organizations/{organization}/projects/{project}/api-clients Create new api client
APIClientsApi ApiClientDelete Delete /organizations/{organization}/projects/{project}/api-clients/{id} Delete an API Client
APIClientsApi ApiClientQuery Get /organizations/{organization}/projects/{project}/api-clients List all api clients
ComponentsApi ComponentCommitQuery Get /organizations/{organization}/projects/{project}/components/{component}/commits List all commits of a component between two versions ordered by creation date. If `to` is not provided, it will list all commits from `from` to the latest version.
ComponentsApi ComponentCreate Post /organizations/{organization}/projects/{project}/components Create component
ComponentsApi ComponentDelete Delete /organizations/{organization}/projects/{project}/components/{component} Delete a component
ComponentsApi ComponentLatestVersion Get /organizations/{organization}/projects/{project}/components/{component}/latest Get last component version
ComponentsApi ComponentPatch Patch /organizations/{organization}/projects/{project}/components/{component} Patch an existing component
ComponentsApi ComponentQuery Get /organizations/{organization}/projects/{project}/components List all components
ComponentsApi ComponentVersionCreate Post /organizations/{organization}/projects/{project}/components/{component}/versions Create component version
ComponentsApi ComponentVersionDelete Delete /organizations/{organization}/projects/{project}/components/{component}/versions/{version} Delete component version
ComponentsApi ComponentVersionGet Get /organizations/{organization}/projects/{project}/components/{component}/versions/{version} Get component version
ComponentsApi ComponentVersionPushCommits Post /organizations/{organization}/projects/{project}/components/{component}/versions/{version}/commits Push commits for this component version
ComponentsApi ComponentVersionQuery Get /organizations/{organization}/projects/{project}/components/{component}/versions List all versions of a component
ComponentsApi ComponentVersionQueryCommits Get /organizations/{organization}/projects/{project}/components/{component}/versions/{version}/commits Get commits for this component version
MyAccountApi MyAccountInformation Get /account/me Get user information
OrganizationManagementApi OrganizationCreate Post /organizations Create new organization
OrganizationManagementApi OrganizationPatch Patch /organizations/{organization} Update an organization
OrganizationManagementApi OrganizationQuery Get /organizations List all organizations
OrganizationManagementApi OrganizationUserInvite Post /organizations/{organization}/users/invite Invite a user to the organization
OrganizationManagementApi OrganizationUserInviteAccept Post /organizations/{organization}/users/invite/{id} Accept a user invite
OrganizationManagementApi OrganizationUserInviteView Get /organizations/{organization}/users/invite/{id} View invite information
OrganizationManagementApi OrganizationUserQuery Get /organizations/{organization}/users List all users in an organization
OrganizationManagementApi ProjectCreate Post /organizations/{organization}/projects Create new project in an organization
OrganizationManagementApi ProjectDelete Delete /organizations/{organization}/projects/{project} Delete a project
OrganizationManagementApi ProjectPatch Patch /organizations/{organization}/projects/{project} Update a Project
OrganizationManagementApi ProjectQuery Get /organizations/{organization}/projects List all projects in an organization
SiteComponentsApi SiteComponentCreate Post /organizations/{organization}/projects/{project}/site-components Create site component
SiteComponentsApi SiteComponentDelete Delete /organizations/{organization}/projects/{project}/site-components/{site-component} Delete a site component
SiteComponentsApi SiteComponentGet Get /organizations/{organization}/projects/{project}/site-components/{site-component} Get an existing site component
SiteComponentsApi SiteComponentPatch Patch /organizations/{organization}/projects/{project}/site-components/{site-component} Patch an existing site component
SiteComponentsApi SiteComponentQuery Get /organizations/{organization}/projects/{project}/site-components List all sites components
SitesApi SiteComponentSiteQuery Get /organizations/{organization}/projects/{project}/sites/{site}/components List all components for the given site
SitesApi SiteCreate Post /organizations/{organization}/projects/{project}/sites Create site
SitesApi SiteDelete Delete /organizations/{organization}/projects/{project}/sites/{site} Delete a site
SitesApi SiteGet Get /organizations/{organization}/projects/{project}/sites/{site} Get an existing site
SitesApi SitePatch Patch /organizations/{organization}/projects/{project}/sites/{site} Patch an existing site
SitesApi SiteQuery Get /organizations/{organization}/projects/{project}/sites List all sites

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

OAuth2
  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
  • api: Grants complete read/write access to the API

Example

auth := context.WithValue(context.Background(), mccsdk.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, mccsdk.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)
OAuth2
  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: http://localhost:3000
  • Scopes:
  • api: Grants complete read/write access to the API

Example

auth := context.WithValue(context.Background(), mccsdk.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, mccsdk.ContextOAuth2, tokenSource)
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

mach@labdigital.nl

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL