citrix-daas-rest-go

module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0

README

Client for Go for use with Citrix DaaS™ APIs

About

The Client for Go for use with Citrix DaaS™ APIs enables managing Citrix DaaS resources programmatically in applications written in the Go programming language.

Installation

  • From GitHub
go get github.com/citrix/citrix-daas-rest-go

Usage

The Client for Go for use with Citrix DaaS APIs contains the following two packages::

  1. github.com/citrix/citrix-daas-rest-go/citrixorchestration: SDK which contains the client model and api functions for Citrix DaaS API. This is auto-generated by OpenAPI Generator and do not require any manual changes.
  2. github.com/citrix/citrix-daas-rest-go/client: Rest client configurable with Citrix DaaS customer details and handles authentication.

Instantiate a client using NewCitrixDaasClient. The following variables are required to configure Citrix DaaS client:

Cloud On-Premises
authUrl Citrix Cloud authentication URL, i.e. https://api-us.cloud.com/cctrustoauth2/{customerId}/tokens/clients for US customers. On-Premises trust service URL, i.e. https://{deliveryControllerHostname}/citrix/orchestration/api/techpreview/tokens
hostname Citrix Cloud DaaS service hostname, i.e. {customerId}.xendesktop.net Delivery Controller Hostname / IP address
customerId Cloud Customer Id CitrixOnPremises
clientId Citrix Cloud API Key clientId Domain Admin Username
clientSecret Citrix Cloud API Key clientSecret Domain Admin Password
onPremise false true

Example

package main

import (
        "context"

        citrixorchestration "github.com/citrix/citrix-daas-rest-go/citrixorchestration"
        citrixclient "github.com/citrix/citrix-daas-rest-go/client"
)

func main() {
        // Create a new Citrix API client for cloud customer 83czxoqlpepv
        authUrl := "https://api-us.cloud.com/cctrustoauth2/83czxoqlpepv/tokens/clients"
        hostname := "83czxoqlpepv.xendesktop.net"
        customerId := "83czxoqlpepv"
        clientId := "{apiKeyClientId}"
        clientSecret := "{apiKeyClientSecret}"
        onPremise := false
        client, err := citrixclient.NewCitrixDaasClient(authUrl, hostname, customerId, clientId, clientSecret, onPremise, nil, nil)
        
        // Create GET zone request with zoneId and siteId
        zoneId := "8994379b-8585-4717-9765-632992e738d3"
        siteId := "8509b2e6-ff02-48bb-aaa3-07b84f09b9f4"
        getZoneRequest := client.ApiClient.ZonesTPApi.ZonesTPGetZone(ctx, zoneId, customerId, siteId)

        // Get bearer token and put into authorization header
        token, _ := client.SignIn()
        getZoneRequest = getZoneRequest.Authorization(token)

        // Execute request and get response
        zone, _, err := getZoneRequest.Execute()
        if err != nil {
            return
        }
}

Attributions

The code in this repository makes use of the following packages:

License

This project is 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.

Copyright © 2023. Citrix Systems, Inc.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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