sdk

package module
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: Apache-2.0 Imports: 0 Imported by: 0

README

Financial Cloud SDK for Go

fincloud-sdk-for-go provides Go packages for managing and using Financial Cloud services. It officially supports the last two major releases of Go. Older versions of Go will be kept running in CI until they no longer work due to changes in any of the SDK's external dependencies. The CHANGELOG will be updated when a version of Go is removed from CI.

Installation

$ go get -u github.com/samjegal/fincloud-sdk-for-go

If you need to install Go, follow the official instructions.

Authentication

Typical SDK operations must be authenticated and authorized. The Authorizer interface allows use of any auth style in requests, such as inserting such as Access and Secret Keys Authorization header token received.

func authorize(sender autorest.Sender, serviceId string) autorest.Authorizer {
	httpMethod := "POST"
	requestUrl := "/sms/v2/services/" + serviceId + "/messages"

	auth := authentication.Builder{
		AccessKeyId: "{{ACCESS_KEY}}",
		SecretKey:   "{{SECRET_KEY}}",
		HttpMethod:  httpMethod,
		RequestURL:  requestUrl,
	}

	env, err := authentication.DetermineEnvironment("FINCLOUD")
	if err != nil {
		panic("Authentication determine set environment failed...")
	}

	config, err := auth.Build()
	if err != nil {
		panic("Authentication build failed...")
	}


	a, err := config.GetAuthorizationToken(sender, env.ResourceManagerEndpoint)
	if err != nil {
		panic("Get Authorization token failed...")
	}

	return a
}

Example

Apply the following general steps to use packages in this repo. For more on authentication and the Authorizer interface see the next section.

  1. Import a package from the services directory.
  2. Create and authenticate a client with a New*Client func, e.g. c := sens.NewSMSClientWithBaseURI(...).
  3. Invoke API methods using the client, e.g. res, err := c.CreateOrUpdate(...).
  4. Handle responses and errors.

For example, to create a new virtual network (substitute your own values for strings in angle brackets):

package main

import (
	"context"
	"fmt"

	"github.com/Azure/go-autorest/autorest"
	"github.com/samjegal/fincloud-sdk-for-go/services/sens"
	"github.com/samjegal/go-fincloud-helpers/authentication"
	"github.com/samjegal/go-fincloud-helpers/sender"
)

func main()  {
	serviceId := "ncp:sms:fkr:256601028628:portal"

	sender := sender.BuildSender("FINCLOUD")
	client := sens.NewSMSClientWithBaseURI("https://sens.apigw.fin-ntruss.com")

	client.Authorizer = authorize(sender, serviceId)
	client.Sender = sender

	param := sens.SMSMessageRequestParameter{
		Type:            stringPtr("SMS"),
		CountryCode:     stringPtr("82"),
		From:            stringPtr("{{SENDER_PHONE_NUMBER}}"),
		Subject:         stringPtr("subject"),
		ContentType:     stringPtr("COMM"),
		Content:         stringPtr("sms"),
		Messages:        &[]sens.SMSMessageRequestParameterMessagesItem{
			{
				Subject: stringPtr("Test Subject"),
				Content: stringPtr("Test Message for SMS"),
				To:      stringPtr("{{OWN_PHONE_NUMBER}}"),
			},
		},
	}

	ctx := context.Background()
	resp, err := client.Request(ctx, serviceId, param)
	if err != nil {
		panic("Send request SMS faild...")
	}
}

Contributing

This repository is inspired by Microsoft Azure SDK for Go. The code is based on azure-sdk-for-go

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
kms
nas
vpc
wms
services
cloudinsight
Package cloudinsight implements the Azure ARM Cloudinsight service API version 0.0.1.
Package cloudinsight implements the Azure ARM Cloudinsight service API version 0.0.1.
compute
Package compute implements the Azure ARM Compute service API version .
Package compute implements the Azure ARM Compute service API version .
geolocation
Package geolocation implements the Azure ARM Geolocation service API version 0.0.1.
Package geolocation implements the Azure ARM Geolocation service API version 0.0.1.
kms
Package kms implements the Azure ARM Kms service API version 1.0.0.
Package kms implements the Azure ARM Kms service API version 1.0.0.
kubernetes
Package kubernetes implements the Azure ARM Kubernetes service API version 2.0.0.
Package kubernetes implements the Azure ARM Kubernetes service API version 2.0.0.
loadbalancer
Package loadbalancer implements the Azure ARM Loadbalancer service API version 0.0.1.
Package loadbalancer implements the Azure ARM Loadbalancer service API version 0.0.1.
location
Package location implements the Azure ARM Location service API version 0.0.1.
Package location implements the Azure ARM Location service API version 0.0.1.
nas
Package nas implements the Azure ARM Nas service API version 1.0.0.
Package nas implements the Azure ARM Nas service API version 1.0.0.
network
Package network implements the Azure ARM Network service API version .
Package network implements the Azure ARM Network service API version .
outboundmailer
Package outboundmailer implements the Azure ARM Outboundmailer service API version 0.0.1.
Package outboundmailer implements the Azure ARM Outboundmailer service API version 0.0.1.
partner
Package partner implements the Azure ARM Partner service API version 1.0.0.
Package partner implements the Azure ARM Partner service API version 1.0.0.
registry
Package registry implements the Azure ARM Registry service API version 2020-02-19T12:58:42Z. Container Registry Client
Package registry implements the Azure ARM Registry service API version 2020-02-19T12:58:42Z. Container Registry Client
sens
Package sens implements the Azure ARM Sens service API version 2019-10-23T06:20:43Z. SENS Client
Package sens implements the Azure ARM Sens service API version 2019-10-23T06:20:43Z. SENS Client
server
Package server implements the Azure ARM Server service API version 1.0.0.
Package server implements the Azure ARM Server service API version 1.0.0.
sslvpn
Package sslvpn implements the Azure ARM Sslvpn service API version 0.0.1.
Package sslvpn implements the Azure ARM Sslvpn service API version 0.0.1.
vpc
Package vpc implements the Azure ARM Vpc service API version 1.0.0.
Package vpc implements the Azure ARM Vpc service API version 1.0.0.
wms
Package wms implements the Azure ARM Wms service API version 0.0.1.
Package wms implements the Azure ARM Wms service API version 0.0.1.
tools

Jump to

Keyboard shortcuts

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