package apibuilderapi /** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.1-dev * User agent: apibuilder app.apibuilder.io/secret/apibuilder-api/0.0.1-dev/go_1_5_client */ import ( "applications" "bytes" "encoding/json" "errors" "fmt" "html" "io" "io/apibuilder/common" "io/apibuilder/generator" "io/apibuilder/spec" "io/ioutil" "membership_requests" "memberships" "net/http" "net/url" "strconv" "strings" "versions" ) const BaseUrl = "https://api.apibuilder.io" const UserAgent = "apibuilder app.apibuilder.io/secret/apibuilder-api/0.0.1-dev/go_1_5_client" const Version = "0.0.1-dev" const VersionMajor = 0 type Client struct { HttpClient *http.Client Username string Password string BaseUrl string Headers http.Header } type ClientRequestBody struct { contentType string bytes io.Reader } type AppSortBy string const ( AppSortByName AppSortBy = "name" AppSortByCreatedAt = "created_at" AppSortByUpdatedAt = "updated_at" AppSortByVisibility = "visibility" AppSortByUNDEFINED = "UNDEFINED" ) func AppSortByFromString(value string) AppSortBy { switch strings.TrimSpace(strings.ToLower(value)) { case "name": return AppSortByName case "created_at": return AppSortByCreatedAt case "updated_at": return AppSortByUpdatedAt case "visibility": return AppSortByVisibility default: return AppSortByUNDEFINED } } type OriginalType string const ( OriginalTypeApiJson OriginalType = "api_json" // The original is in the api.json format OriginalTypeAvroIdl = "avro_idl" // The original is in Avro Idl format OriginalTypeServiceJson = "service_json" // This is the canonical service spec for apibuilder itself. See https://www.apibuilder.io/apicollective/apibuilder-spec/latest#model-service OriginalTypeSwagger = "swagger" // The original in the Swagger JSON or YAML format OriginalTypeUNDEFINED = "UNDEFINED" ) func OriginalTypeFromString(value string) OriginalType { switch strings.TrimSpace(strings.ToLower(value)) { case "api_json": return OriginalTypeApiJson case "avro_idl": return OriginalTypeAvroIdl case "service_json": return OriginalTypeServiceJson case "swagger": return OriginalTypeSwagger default: return OriginalTypeUNDEFINED } } /** * A publication represents something that a user can subscribe to. An example * would be subscribing to an email alert whenever a new version of an application * is created. */ type Publication string const ( Publicationmembership_requests.Create Publication = "membership_requests.create" // For organizations for which I am an administrator, email me whenever a user applies to join the org. Publicationmemberships.Create = "memberships.create" // For organizations for which I am a member, email me whenever a user joins the org. Publicationapplications.Create = "applications.create" // For organizations for which I am a member, email me whenever an application is created. Publicationversions.Create = "versions.create" // For applications that I watch, email me whenever a version is created. PublicationUNDEFINED = "UNDEFINED" ) func PublicationFromString(value string) Publication { switch strings.TrimSpace(strings.ToLower(value)) { case "membership_requests.create": return Publicationmembership_requests.Create case "memberships.create": return Publicationmemberships.Create case "applications.create": return Publicationapplications.Create case "versions.create": return Publicationversions.Create default: return PublicationUNDEFINED } } type SortOrder string const ( SortOrderAsc SortOrder = "asc" SortOrderDesc = "desc" SortOrderUNDEFINED = "UNDEFINED" ) func SortOrderFromString(value string) SortOrder { switch strings.TrimSpace(strings.ToLower(value)) { case "asc": return SortOrderAsc case "desc": return SortOrderDesc default: return SortOrderUNDEFINED } } /** * Controls who is able to view this version */ type Visibility string const ( VisibilityUser Visibility = "user" // Only the creator can view this application VisibilityOrganization = "organization" // Any member of the organization can view this application VisibilityPublic = "public" // Anybody, including non logged in users, can view this application VisibilityUNDEFINED = "UNDEFINED" ) func VisibilityFromString(value string) Visibility { switch strings.TrimSpace(strings.ToLower(value)) { case "user": return VisibilityUser case "organization": return VisibilityOrganization case "public": return VisibilityPublic default: return VisibilityUNDEFINED } } /** * An application has a name and multiple versions of its API. */ type Application struct { Guid string `json:"guid"` Organization common.Reference `json:"organization"` Name string `json:"name"` Key string `json:"key"` Visibility Visibility `json:"visibility"` Description string `json:"description,omitempty"` LastUpdatedAt string `json:"last_updated_at"` Audit common.Audit `json:"audit"` } func ApplicationFromMap(data interface{}) Application { b, err := json.Marshal(data) if err == nil { return ApplicationFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationFromJson(bytes io.Reader) Application { var application Application json.NewDecoder(bytes).Decode(&application) return application } type ApplicationForm struct { Name string `json:"name"` Key string `json:"key,omitempty"` Description string `json:"description,omitempty"` Visibility Visibility `json:"visibility"` } func ApplicationFormFromMap(data interface{}) ApplicationForm { b, err := json.Marshal(data) if err == nil { return ApplicationFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationFormFromJson(bytes io.Reader) ApplicationForm { var applicationForm ApplicationForm json.NewDecoder(bytes).Decode(&applicationForm) return applicationForm } type ApplicationMetadata struct { Guid string `json:"guid"` Key string `json:"key"` } func ApplicationMetadataFromMap(data interface{}) ApplicationMetadata { b, err := json.Marshal(data) if err == nil { return ApplicationMetadataFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationMetadataFromJson(bytes io.Reader) ApplicationMetadata { var applicationMetadata ApplicationMetadata json.NewDecoder(bytes).Decode(&applicationMetadata) return applicationMetadata } /** * Describes the versions associated with a given application */ type ApplicationMetadataVersion struct { Version string `json:"version"` } func ApplicationMetadataVersionFromMap(data interface{}) ApplicationMetadataVersion { b, err := json.Marshal(data) if err == nil { return ApplicationMetadataVersionFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationMetadataVersionFromJson(bytes io.Reader) ApplicationMetadataVersion { var applicationMetadataVersion ApplicationMetadataVersion json.NewDecoder(bytes).Decode(&applicationMetadataVersion) return applicationMetadataVersion } /** * Summary of an application sufficient for display and links */ type ApplicationSummary struct { Guid string `json:"guid"` Organization common.Reference `json:"organization"` Key string `json:"key"` } func ApplicationSummaryFromMap(data interface{}) ApplicationSummary { b, err := json.Marshal(data) if err == nil { return ApplicationSummaryFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationSummaryFromJson(bytes io.Reader) ApplicationSummary { var applicationSummary ApplicationSummary json.NewDecoder(bytes).Decode(&applicationSummary) return applicationSummary } /** * Attributes are globally unique key which allow users to specify additional * content to pass in to the code generators. */ type Attribute struct { Guid string `json:"guid"` Name string `json:"name"` Description string `json:"description,omitempty"` Audit common.Audit `json:"audit"` } func AttributeFromMap(data interface{}) Attribute { b, err := json.Marshal(data) if err == nil { return AttributeFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeFromJson(bytes io.Reader) Attribute { var attribute Attribute json.NewDecoder(bytes).Decode(&attribute) return attribute } type AttributeForm struct { Name string `json:"name"` Description string `json:"description,omitempty"` } func AttributeFormFromMap(data interface{}) AttributeForm { b, err := json.Marshal(data) if err == nil { return AttributeFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeFormFromJson(bytes io.Reader) AttributeForm { var attributeForm AttributeForm json.NewDecoder(bytes).Decode(&attributeForm) return attributeForm } type AttributeSummary struct { Guid string `json:"guid"` Name string `json:"name"` } func AttributeSummaryFromMap(data interface{}) AttributeSummary { b, err := json.Marshal(data) if err == nil { return AttributeSummaryFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeSummaryFromJson(bytes io.Reader) AttributeSummary { var attributeSummary AttributeSummary json.NewDecoder(bytes).Decode(&attributeSummary) return attributeSummary } /** * Attribute values can be set at different levels. Initially we support setting * organization wide attributes, but in the future plan to support setting * attribute values with each version of the application. */ type AttributeValue struct { Guid string `json:"guid"` Attribute AttributeSummary `json:"attribute"` Value string `json:"value"` Audit common.Audit `json:"audit"` } func AttributeValueFromMap(data interface{}) AttributeValue { b, err := json.Marshal(data) if err == nil { return AttributeValueFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeValueFromJson(bytes io.Reader) AttributeValue { var attributeValue AttributeValue json.NewDecoder(bytes).Decode(&attributeValue) return attributeValue } type AttributeValueForm struct { Value string `json:"value"` } func AttributeValueFormFromMap(data interface{}) AttributeValueForm { b, err := json.Marshal(data) if err == nil { return AttributeValueFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeValueFormFromJson(bytes io.Reader) AttributeValueForm { var attributeValueForm AttributeValueForm json.NewDecoder(bytes).Decode(&attributeValueForm) return attributeValueForm } /** * Represents the result of a successful authorization */ type Authentication struct { User User `json:"user"` Session Session `json:"session"` } func AuthenticationFromMap(data interface{}) Authentication { b, err := json.Marshal(data) if err == nil { return AuthenticationFromJson(bytes.NewReader(b)) } else { panic(err) } } func AuthenticationFromJson(bytes io.Reader) Authentication { var authentication Authentication json.NewDecoder(bytes).Decode(&authentication) return authentication } /** * Represents a single change from one version of a service to another */ type Change struct { Guid string `json:"guid"` Organization common.Reference `json:"organization"` Application common.Reference `json:"application"` FromVersion ChangeVersion `json:"from_version"` ToVersion ChangeVersion `json:"to_version"` Diff Diff `json:"diff"` ChangedAt string `json:"changed_at"` ChangedBy UserSummary `json:"changed_by"` Audit common.Audit `json:"audit"` } func ChangeFromMap(data interface{}) Change { b, err := json.Marshal(data) if err == nil { return ChangeFromJson(bytes.NewReader(b)) } else { panic(err) } } func ChangeFromJson(bytes io.Reader) Change { var change Change json.NewDecoder(bytes).Decode(&change) return change } /** * Represents a simpler model of a version specifically for the use case of * displaying changes */ type ChangeVersion struct { Guid string `json:"guid"` Version string `json:"version"` } func ChangeVersionFromMap(data interface{}) ChangeVersion { b, err := json.Marshal(data) if err == nil { return ChangeVersionFromJson(bytes.NewReader(b)) } else { panic(err) } } func ChangeVersionFromJson(bytes io.Reader) ChangeVersion { var changeVersion ChangeVersion json.NewDecoder(bytes).Decode(&changeVersion) return changeVersion } /** * Separate resource used only for the few actions that require the full token. */ type CleartextToken struct { Token string `json:"token"` } func CleartextTokenFromMap(data interface{}) CleartextToken { b, err := json.Marshal(data) if err == nil { return CleartextTokenFromJson(bytes.NewReader(b)) } else { panic(err) } } func CleartextTokenFromJson(bytes io.Reader) CleartextToken { var cleartextToken CleartextToken json.NewDecoder(bytes).Decode(&cleartextToken) return cleartextToken } /** * Generated source code. */ type Code struct { Generator GeneratorWithService `json:"generator"` Source string `json:"source"` Files []generator.File `json:"files"` } func CodeFromMap(data interface{}) Code { b, err := json.Marshal(data) if err == nil { return CodeFromJson(bytes.NewReader(b)) } else { panic(err) } } func CodeFromJson(bytes io.Reader) Code { var code Code json.NewDecoder(bytes).Decode(&code) return code } type CodeForm struct { Attributes []generator.Attribute `json:"attributes"` } func CodeFormFromMap(data interface{}) CodeForm { b, err := json.Marshal(data) if err == nil { return CodeFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func CodeFormFromJson(bytes io.Reader) CodeForm { var codeForm CodeForm json.NewDecoder(bytes).Decode(&codeForm) return codeForm } /** * Represents a single breaking diff of an application version. A breaking diff * indicates that it is possible for an existing client to now experience an error * or invalid data due to the diff. */ type DiffBreaking struct { Description string `json:"description"` } func DiffBreakingFromMap(data interface{}) DiffBreaking { b, err := json.Marshal(data) if err == nil { return DiffBreakingFromJson(bytes.NewReader(b)) } else { panic(err) } } func DiffBreakingFromJson(bytes io.Reader) DiffBreaking { var diffBreaking DiffBreaking json.NewDecoder(bytes).Decode(&diffBreaking) return diffBreaking } /** * Represents a single NON breaking diff of an application version. */ type DiffNonBreaking struct { Description string `json:"description"` } func DiffNonBreakingFromMap(data interface{}) DiffNonBreaking { b, err := json.Marshal(data) if err == nil { return DiffNonBreakingFromJson(bytes.NewReader(b)) } else { panic(err) } } func DiffNonBreakingFromJson(bytes io.Reader) DiffNonBreaking { var diffNonBreaking DiffNonBreaking json.NewDecoder(bytes).Decode(&diffNonBreaking) return diffNonBreaking } /** * Represents a single domain name (e.g. www.apibuilder.io). When a new user * registers and confirms their email, we automatically associate that user with a * member of the organization associated with their domain. For example, if you * confirm your account with an email address of example@somedomain.com, we will * automatically create a membership request on your behalf to join the * organization with domain somedomain.com. */ type Domain struct { Name string `json:"name"` } func DomainFromMap(data interface{}) Domain { b, err := json.Marshal(data) if err == nil { return DomainFromJson(bytes.NewReader(b)) } else { panic(err) } } func DomainFromJson(bytes io.Reader) Domain { var domain Domain json.NewDecoder(bytes).Decode(&domain) return domain } /** * Data used to confirm an email address. The token is an internal unique * identifier used to lookup the specific email address and user account for which * we sent an email verification email. */ type EmailVerificationConfirmationForm struct { Token string `json:"token"` } func EmailVerificationConfirmationFormFromMap(data interface{}) EmailVerificationConfirmationForm { b, err := json.Marshal(data) if err == nil { return EmailVerificationConfirmationFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func EmailVerificationConfirmationFormFromJson(bytes io.Reader) EmailVerificationConfirmationForm { var emailVerificationConfirmationForm EmailVerificationConfirmationForm json.NewDecoder(bytes).Decode(&emailVerificationConfirmationForm) return emailVerificationConfirmationForm } type Error struct { Code string `json:"code"` Message string `json:"message"` } func ErrorFromMap(data interface{}) Error { b, err := json.Marshal(data) if err == nil { return ErrorFromJson(bytes.NewReader(b)) } else { panic(err) } } func ErrorFromJson(bytes io.Reader) Error { var error_ Error json.NewDecoder(bytes).Decode(&error_) return error_ } type GeneratorForm struct { ServiceGuid string `json:"service_guid"` Generator generator.Generator `json:"generator"` } func GeneratorFormFromMap(data interface{}) GeneratorForm { b, err := json.Marshal(data) if err == nil { return GeneratorFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func GeneratorFormFromJson(bytes io.Reader) GeneratorForm { var generatorForm GeneratorForm json.NewDecoder(bytes).Decode(&generatorForm) return generatorForm } /** * Defines a service that provides one or more code generators */ type GeneratorService struct { Guid string `json:"guid"` Uri string `json:"uri"` Audit common.Audit `json:"audit"` } func GeneratorServiceFromMap(data interface{}) GeneratorService { b, err := json.Marshal(data) if err == nil { return GeneratorServiceFromJson(bytes.NewReader(b)) } else { panic(err) } } func GeneratorServiceFromJson(bytes io.Reader) GeneratorService { var generatorService GeneratorService json.NewDecoder(bytes).Decode(&generatorService) return generatorService } type GeneratorServiceForm struct { Uri string `json:"uri"` } func GeneratorServiceFormFromMap(data interface{}) GeneratorServiceForm { b, err := json.Marshal(data) if err == nil { return GeneratorServiceFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func GeneratorServiceFormFromJson(bytes io.Reader) GeneratorServiceForm { var generatorServiceForm GeneratorServiceForm json.NewDecoder(bytes).Decode(&generatorServiceForm) return generatorServiceForm } /** * Wraps a service and a generator providing easier access for applications. */ type GeneratorWithService struct { Service GeneratorService `json:"service"` Generator generator.Generator `json:"generator"` } func GeneratorWithServiceFromMap(data interface{}) GeneratorWithService { b, err := json.Marshal(data) if err == nil { return GeneratorWithServiceFromJson(bytes.NewReader(b)) } else { panic(err) } } func GeneratorWithServiceFromJson(bytes io.Reader) GeneratorWithService { var generatorWithService GeneratorWithService json.NewDecoder(bytes).Decode(&generatorWithService) return generatorWithService } /** * When searching for content, the results of the search will be a list of items. * Each item will have enough information to render for the user, including a type * and item_guid to enable creating the appropriate link. */ type Item struct { Guid string `json:"guid"` Detail ItemDetail `json:"detail"` Label string `json:"label"` Description string `json:"description,omitempty"` } func ItemFromMap(data interface{}) Item { b, err := json.Marshal(data) if err == nil { return ItemFromJson(bytes.NewReader(b)) } else { panic(err) } } func ItemFromJson(bytes io.Reader) Item { var item Item json.NewDecoder(bytes).Decode(&item) return item } /** * A membership represents a user in a specific role to an organization. * Memberships cannot be created directly. Instead you first create a membership * request, then that request is either accepted or declined. */ type Membership struct { Guid string `json:"guid"` User User `json:"user"` Organization Organization `json:"organization"` Role string `json:"role"` Audit common.Audit `json:"audit"` } func MembershipFromMap(data interface{}) Membership { b, err := json.Marshal(data) if err == nil { return MembershipFromJson(bytes.NewReader(b)) } else { panic(err) } } func MembershipFromJson(bytes io.Reader) Membership { var membership Membership json.NewDecoder(bytes).Decode(&membership) return membership } /** * A membership request represents a user requesting to join an organization with a * specific role (e.g. as a member or an admin). Membership requests can be * reviewed by any current admin of the organization who can either accept or * decline the request. */ type MembershipRequest struct { Guid string `json:"guid"` User User `json:"user"` Organization Organization `json:"organization"` Role string `json:"role"` Audit common.Audit `json:"audit"` } func MembershipRequestFromMap(data interface{}) MembershipRequest { b, err := json.Marshal(data) if err == nil { return MembershipRequestFromJson(bytes.NewReader(b)) } else { panic(err) } } func MembershipRequestFromJson(bytes io.Reader) MembershipRequest { var membershipRequest MembershipRequest json.NewDecoder(bytes).Decode(&membershipRequest) return membershipRequest } type MoveForm struct { OrgKey string `json:"org_key"` } func MoveFormFromMap(data interface{}) MoveForm { b, err := json.Marshal(data) if err == nil { return MoveFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func MoveFormFromJson(bytes io.Reader) MoveForm { var moveForm MoveForm json.NewDecoder(bytes).Decode(&moveForm) return moveForm } /** * An organization is used to group a set of applications together. */ type Organization struct { Guid string `json:"guid"` Key string `json:"key"` Name string `json:"name"` Namespace string `json:"namespace"` Visibility Visibility `json:"visibility"` Domains []Domain `json:"domains"` Audit common.Audit `json:"audit"` } func OrganizationFromMap(data interface{}) Organization { b, err := json.Marshal(data) if err == nil { return OrganizationFromJson(bytes.NewReader(b)) } else { panic(err) } } func OrganizationFromJson(bytes io.Reader) Organization { var organization Organization json.NewDecoder(bytes).Decode(&organization) return organization } type OrganizationForm struct { Name string `json:"name"` Key string `json:"key,omitempty"` Namespace string `json:"namespace"` Visibility Visibility `json:"visibility"` Domains []string `json:"domains,omitempty"` } func OrganizationFormFromMap(data interface{}) OrganizationForm { b, err := json.Marshal(data) if err == nil { return OrganizationFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func OrganizationFormFromJson(bytes io.Reader) OrganizationForm { var organizationForm OrganizationForm json.NewDecoder(bytes).Decode(&organizationForm) return organizationForm } /** * Represents the original input used to create an application version */ type Original struct { Type OriginalType `json:"type"` Data string `json:"data"` } func OriginalFromMap(data interface{}) Original { b, err := json.Marshal(data) if err == nil { return OriginalFromJson(bytes.NewReader(b)) } else { panic(err) } } func OriginalFromJson(bytes io.Reader) Original { var original Original json.NewDecoder(bytes).Decode(&original) return original } type OriginalForm struct { Type OriginalType `json:"type,omitempty"` Data string `json:"data"` } func OriginalFormFromMap(data interface{}) OriginalForm { b, err := json.Marshal(data) if err == nil { return OriginalFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func OriginalFormFromJson(bytes io.Reader) OriginalForm { var originalForm OriginalForm json.NewDecoder(bytes).Decode(&originalForm) return originalForm } /** * Allows a user to change their password with authentication from a token. */ type PasswordReset struct { Token string `json:"token"` Password string `json:"password"` } func PasswordResetFromMap(data interface{}) PasswordReset { b, err := json.Marshal(data) if err == nil { return PasswordResetFromJson(bytes.NewReader(b)) } else { panic(err) } } func PasswordResetFromJson(bytes io.Reader) PasswordReset { var passwordReset PasswordReset json.NewDecoder(bytes).Decode(&passwordReset) return passwordReset } /** * Create a password reset request - e.g. an email containing a one time URL to * change a password */ type PasswordResetRequest struct { Email string `json:"email"` } func PasswordResetRequestFromMap(data interface{}) PasswordResetRequest { b, err := json.Marshal(data) if err == nil { return PasswordResetRequestFromJson(bytes.NewReader(b)) } else { panic(err) } } func PasswordResetRequestFromJson(bytes io.Reader) PasswordResetRequest { var passwordResetRequest PasswordResetRequest json.NewDecoder(bytes).Decode(&passwordResetRequest) return passwordResetRequest } /** * Represents a user sessions (e.g. user logged into site) */ type Session struct { Id string `json:"id"` ExpiresAt string `json:"expires_at"` } func SessionFromMap(data interface{}) Session { b, err := json.Marshal(data) if err == nil { return SessionFromJson(bytes.NewReader(b)) } else { panic(err) } } func SessionFromJson(bytes io.Reader) Session { var session Session json.NewDecoder(bytes).Decode(&session) return session } /** * Represents a user that is currently subscribed to a publication */ type Subscription struct { Guid string `json:"guid"` Organization Organization `json:"organization"` User User `json:"user"` Publication Publication `json:"publication"` Audit common.Audit `json:"audit"` } func SubscriptionFromMap(data interface{}) Subscription { b, err := json.Marshal(data) if err == nil { return SubscriptionFromJson(bytes.NewReader(b)) } else { panic(err) } } func SubscriptionFromJson(bytes io.Reader) Subscription { var subscription Subscription json.NewDecoder(bytes).Decode(&subscription) return subscription } type SubscriptionForm struct { OrganizationKey string `json:"organization_key"` UserGuid string `json:"user_guid"` Publication Publication `json:"publication"` } func SubscriptionFormFromMap(data interface{}) SubscriptionForm { b, err := json.Marshal(data) if err == nil { return SubscriptionFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func SubscriptionFormFromJson(bytes io.Reader) SubscriptionForm { var subscriptionForm SubscriptionForm json.NewDecoder(bytes).Decode(&subscriptionForm) return subscriptionForm } /** * A token gives a user access to the API. */ type Token struct { Guid string `json:"guid"` User User `json:"user"` MaskedToken string `json:"masked_token"` Description string `json:"description,omitempty"` Audit common.Audit `json:"audit"` } func TokenFromMap(data interface{}) Token { b, err := json.Marshal(data) if err == nil { return TokenFromJson(bytes.NewReader(b)) } else { panic(err) } } func TokenFromJson(bytes io.Reader) Token { var token Token json.NewDecoder(bytes).Decode(&token) return token } type TokenForm struct { UserGuid string `json:"user_guid"` Description string `json:"description,omitempty"` } func TokenFormFromMap(data interface{}) TokenForm { b, err := json.Marshal(data) if err == nil { return TokenFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func TokenFormFromJson(bytes io.Reader) TokenForm { var tokenForm TokenForm json.NewDecoder(bytes).Decode(&tokenForm) return tokenForm } /** * A user is a top level person interacting with the api doc server. */ type User struct { Guid string `json:"guid"` Email string `json:"email"` Nickname string `json:"nickname"` Name string `json:"name,omitempty"` Audit common.Audit `json:"audit"` } func UserFromMap(data interface{}) User { b, err := json.Marshal(data) if err == nil { return UserFromJson(bytes.NewReader(b)) } else { panic(err) } } func UserFromJson(bytes io.Reader) User { var user User json.NewDecoder(bytes).Decode(&user) return user } type UserForm struct { Email string `json:"email"` Password string `json:"password"` Nickname string `json:"nickname,omitempty"` Name string `json:"name,omitempty"` } func UserFormFromMap(data interface{}) UserForm { b, err := json.Marshal(data) if err == nil { return UserFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func UserFormFromJson(bytes io.Reader) UserForm { var userForm UserForm json.NewDecoder(bytes).Decode(&userForm) return userForm } /** * Summary of a user sufficient for display */ type UserSummary struct { Guid string `json:"guid"` Nickname string `json:"nickname"` } func UserSummaryFromMap(data interface{}) UserSummary { b, err := json.Marshal(data) if err == nil { return UserSummaryFromJson(bytes.NewReader(b)) } else { panic(err) } } func UserSummaryFromJson(bytes io.Reader) UserSummary { var userSummary UserSummary json.NewDecoder(bytes).Decode(&userSummary) return userSummary } type UserUpdateForm struct { Email string `json:"email"` Nickname string `json:"nickname"` Name string `json:"name,omitempty"` } func UserUpdateFormFromMap(data interface{}) UserUpdateForm { b, err := json.Marshal(data) if err == nil { return UserUpdateFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func UserUpdateFormFromJson(bytes io.Reader) UserUpdateForm { var userUpdateForm UserUpdateForm json.NewDecoder(bytes).Decode(&userUpdateForm) return userUpdateForm } /** * Used only to validate json files - used as a resource where http status code * defines success */ type Validation struct { Valid string `json:"valid"` Errors []string `json:"errors"` } func ValidationFromMap(data interface{}) Validation { b, err := json.Marshal(data) if err == nil { return ValidationFromJson(bytes.NewReader(b)) } else { panic(err) } } func ValidationFromJson(bytes io.Reader) Validation { var validation Validation json.NewDecoder(bytes).Decode(&validation) return validation } /** * Represents a unique version of the application. */ type Version struct { Guid string `json:"guid"` Organization common.Reference `json:"organization"` Application common.Reference `json:"application"` Version string `json:"version"` Original Original `json:"original,omitempty"` Service spec.Service `json:"service"` Audit common.Audit `json:"audit"` } func VersionFromMap(data interface{}) Version { b, err := json.Marshal(data) if err == nil { return VersionFromJson(bytes.NewReader(b)) } else { panic(err) } } func VersionFromJson(bytes io.Reader) Version { var version Version json.NewDecoder(bytes).Decode(&version) return version } type VersionForm struct { OriginalForm OriginalForm `json:"original_form"` Visibility Visibility `json:"visibility,omitempty"` } func VersionFormFromMap(data interface{}) VersionForm { b, err := json.Marshal(data) if err == nil { return VersionFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func VersionFormFromJson(bytes io.Reader) VersionForm { var versionForm VersionForm json.NewDecoder(bytes).Decode(&versionForm) return versionForm } /** * Users can watch individual applications which enables features like receiving an * email notification when there is a new version of an application. */ type Watch struct { Guid string `json:"guid"` User User `json:"user"` Organization Organization `json:"organization"` Application Application `json:"application"` Audit common.Audit `json:"audit"` } func WatchFromMap(data interface{}) Watch { b, err := json.Marshal(data) if err == nil { return WatchFromJson(bytes.NewReader(b)) } else { panic(err) } } func WatchFromJson(bytes io.Reader) Watch { var watch Watch json.NewDecoder(bytes).Decode(&watch) return watch } type WatchForm struct { UserGuid string `json:"user_guid"` OrganizationKey string `json:"organization_key"` ApplicationKey string `json:"application_key"` } func WatchFormFromMap(data interface{}) WatchForm { b, err := json.Marshal(data) if err == nil { return WatchFormFromJson(bytes.NewReader(b)) } else { panic(err) } } func WatchFormFromJson(bytes io.Reader) WatchForm { var watchForm WatchForm json.NewDecoder(bytes).Decode(&watchForm) return watchForm } /** * Represents a single diff in an application */ type Diff struct { DiffBreaking DiffBreaking DiffNonBreaking DiffNonBreaking Undefined string } func DiffFromMap(data interface{}) Diff { b, err := json.Marshal(data) if err == nil { return DiffFromJson(bytes.NewReader(b)) } else { panic(err) } } func DiffFromJson(bytes io.Reader) Diff { var el map[string]interface{} json.NewDecoder(bytes).Decode(&el) switch el["type"] { case "diff_breaking": return Diff{DiffBreaking: DiffBreakingFromMap(el)} case "diff_non_breaking": return Diff{DiffNonBreaking: DiffNonBreakingFromMap(el)} default: return Diff{Undefined: el["type"].(string)} } } /** * Identifies the specific type of item that was indexed by search */ type ItemDetail struct { ApplicationSummary ApplicationSummary Undefined string } func ItemDetailFromMap(data interface{}) ItemDetail { b, err := json.Marshal(data) if err == nil { return ItemDetailFromJson(bytes.NewReader(b)) } else { panic(err) } } func ItemDetailFromJson(bytes io.Reader) ItemDetail { var el map[string]interface{} json.NewDecoder(bytes).Decode(&el) switch el["type"] { case "application_summary": return ItemDetail{ApplicationSummary: ApplicationSummaryFromMap(el)} default: return ItemDetail{Undefined: el["type"].(string)} } } type ApplicationsGetMetadataAndVersionsByApplicationKeyParams struct { Limit int64 Offset int64 } type ApplicationsGetMetadataAndVersionsByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error ApplicationMetadataVersions []ApplicationMetadataVersion } func ApplicationsGetMetadataAndVersionsByApplicationKey(client Client, orgKey string, applicationKey string, params ApplicationsGetMetadataAndVersionsByApplicationKeyParams) ApplicationsGetMetadataAndVersionsByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/metadata/%s/versions", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) urlValues := url.Values{} if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, ApplicationMetadataVersions: func() []ApplicationMetadataVersion { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []ApplicationMetadataVersion for _, el := range tmp { all = append(all, ApplicationMetadataVersionFromMap(el)) } return all }()} case 401: return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return ApplicationsGetMetadataAndVersionsByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error Value string } func ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKey(client Client, orgKey string, applicationKey string) ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/metadata/%s/versions/latest.txt", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Value: func() string { body, _ := ioutil.ReadAll(resp.Body) return string(body) }()} case 401: return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return ApplicationsGetMetadataAndVersionsAndLatestTxtByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsGetParams struct { Name string Guid string Key string HasVersion string Limit int64 Offset int64 SortBy AppSortBy Order SortOrder } type ApplicationsGetResponse struct { StatusCode int Response *http.Response Error error Applications []Application } func ApplicationsGet(client Client, orgKey string, params ApplicationsGetParams) ApplicationsGetResponse { requestUrl := fmt.Sprintf("%s/%s", client.BaseUrl, html.EscapeString(orgKey)) urlValues := url.Values{} if "" != params.Name { urlValues.Add("name", params.Name) } if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.Key { urlValues.Add("key", params.Key) } if "" != params.HasVersion { urlValues.Add("has_version", params.HasVersion) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } if "" != params.SortBy { urlValues.Add("sort_by", string(params.SortBy)) } if "" != params.Order { urlValues.Add("order", string(params.Order)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ApplicationsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsGetResponse{StatusCode: resp.StatusCode, Response: resp, Applications: func() []Application { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Application for _, el := range tmp { all = append(all, ApplicationFromMap(el)) } return all }()} default: return ApplicationsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsPostResponse struct { StatusCode int Response *http.Response Error error Application Application ErrorS []Error } func ApplicationsPost(client Client, orgKey string, applicationForm ApplicationForm) ApplicationsPostResponse { requestUrl := fmt.Sprintf("%s/%s", client.BaseUrl, html.EscapeString(orgKey)) bodyDocument, err := json.Marshal(applicationForm) if err != nil { return ApplicationsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return ApplicationsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Application: ApplicationFromJson(resp.Body)} case 409: return ApplicationsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return ApplicationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsPutByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error Application Application ErrorS []Error } func ApplicationsPutByApplicationKey(client Client, orgKey string, applicationKey string, applicationForm ApplicationForm) ApplicationsPutByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) bodyDocument, err := json.Marshal(applicationForm) if err != nil { return ApplicationsPutByApplicationKeyResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return ApplicationsPutByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsPutByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsPutByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Application: ApplicationFromJson(resp.Body)} case 409: return ApplicationsPutByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return ApplicationsPutByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsDeleteByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error } func ApplicationsDeleteByApplicationKey(client Client, orgKey string, applicationKey string) ApplicationsDeleteByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return ApplicationsDeleteByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsDeleteByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return ApplicationsDeleteByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return ApplicationsDeleteByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return ApplicationsDeleteByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return ApplicationsDeleteByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ApplicationsPostMoveByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error Application Application ErrorS []Error } func ApplicationsPostMoveByApplicationKey(client Client, orgKey string, applicationKey string, moveForm MoveForm) ApplicationsPostMoveByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s/move", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) bodyDocument, err := json.Marshal(moveForm) if err != nil { return ApplicationsPostMoveByApplicationKeyResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return ApplicationsPostMoveByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ApplicationsPostMoveByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ApplicationsPostMoveByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Application: ApplicationFromJson(resp.Body)} case 409: return ApplicationsPostMoveByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return ApplicationsPostMoveByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AttributesGetParams struct { Guid string Name string Limit int64 Offset int64 } type AttributesGetResponse struct { StatusCode int Response *http.Response Error error Attributes []Attribute } func AttributesGet(client Client, params AttributesGetParams) AttributesGetResponse { requestUrl := fmt.Sprintf("%s/attributes", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.Name { urlValues.Add("name", params.Name) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return AttributesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AttributesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AttributesGetResponse{StatusCode: resp.StatusCode, Response: resp, Attributes: func() []Attribute { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Attribute for _, el := range tmp { all = append(all, AttributeFromMap(el)) } return all }()} default: return AttributesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AttributesGetByNameResponse struct { StatusCode int Response *http.Response Error error Attribute Attribute } func AttributesGetByName(client Client, name string) AttributesGetByNameResponse { requestUrl := fmt.Sprintf("%s/attributes/%s", client.BaseUrl, html.EscapeString(name)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return AttributesGetByNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AttributesGetByNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AttributesGetByNameResponse{StatusCode: resp.StatusCode, Response: resp, Attribute: AttributeFromJson(resp.Body)} case 404: return AttributesGetByNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return AttributesGetByNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AttributesPostResponse struct { StatusCode int Response *http.Response Error error Attribute Attribute ErrorS []Error } func AttributesPost(client Client, attributeForm AttributeForm) AttributesPostResponse { requestUrl := fmt.Sprintf("%s/attributes", client.BaseUrl) bodyDocument, err := json.Marshal(attributeForm) if err != nil { return AttributesPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return AttributesPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AttributesPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 201: return AttributesPostResponse{StatusCode: resp.StatusCode, Response: resp, Attribute: AttributeFromJson(resp.Body)} case 401: return AttributesPostResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return AttributesPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return AttributesPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AttributesDeleteByNameResponse struct { StatusCode int Response *http.Response Error error } func AttributesDeleteByName(client Client, name string) AttributesDeleteByNameResponse { requestUrl := fmt.Sprintf("%s/attributes/%s", client.BaseUrl, html.EscapeString(name)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return AttributesDeleteByNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AttributesDeleteByNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return AttributesDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return AttributesDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return AttributesDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return AttributesDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type AuthenticationsGetSessionByIdResponse struct { StatusCode int Response *http.Response Error error Authentication Authentication } func AuthenticationsGetSessionById(client Client, id string) AuthenticationsGetSessionByIdResponse { requestUrl := fmt.Sprintf("%s/authentications/session/%s", client.BaseUrl, html.EscapeString(id)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return AuthenticationsGetSessionByIdResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return AuthenticationsGetSessionByIdResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return AuthenticationsGetSessionByIdResponse{StatusCode: resp.StatusCode, Response: resp, Authentication: AuthenticationFromJson(resp.Body)} case 404: return AuthenticationsGetSessionByIdResponse{StatusCode: resp.StatusCode, Response: resp} default: return AuthenticationsGetSessionByIdResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ChangesGetParams struct { OrgKey string ApplicationKey string From string To string Type string Limit int64 Offset int64 } type ChangesGetResponse struct { StatusCode int Response *http.Response Error error Changes []Change } func ChangesGet(client Client, params ChangesGetParams) ChangesGetResponse { requestUrl := fmt.Sprintf("%s/changes", client.BaseUrl) urlValues := url.Values{} if "" != params.OrgKey { urlValues.Add("org_key", params.OrgKey) } if "" != params.ApplicationKey { urlValues.Add("application_key", params.ApplicationKey) } if "" != params.From { urlValues.Add("from", params.From) } if "" != params.To { urlValues.Add("to", params.To) } if "" != params.Type { urlValues.Add("type", params.Type) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ChangesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ChangesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ChangesGetResponse{StatusCode: resp.StatusCode, Response: resp, Changes: func() []Change { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Change for _, el := range tmp { all = append(all, ChangeFromMap(el)) } return all }()} default: return ChangesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type CodePostFormResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error GeneratorInvocationForm generator.InvocationForm } func CodePostForm(client Client, orgKey string, applicationKey string, version string, codeForm CodeForm) CodePostFormResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s/form", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version)) bodyDocument, err := json.Marshal(codeForm) if err != nil { return CodePostFormResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return CodePostFormResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return CodePostFormResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return CodePostFormResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorInvocationForm: generator.InvocationFormFromJson(resp.Body)} case 409: return CodePostFormResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return CodePostFormResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type CodeGetByGeneratorKeyResponse struct { StatusCode int Response *http.Response Error error Code Code ErrorS []Error } func CodeGetByGeneratorKey(client Client, orgKey string, applicationKey string, version string, generatorKey string) CodeGetByGeneratorKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version), html.EscapeString(generatorKey)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return CodeGetByGeneratorKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return CodeGetByGeneratorKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return CodeGetByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, Code: CodeFromJson(resp.Body)} case 409: return CodeGetByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return CodeGetByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type CodePostByGeneratorKeyResponse struct { StatusCode int Response *http.Response Error error Code Code ErrorS []Error } func CodePostByGeneratorKey(client Client, orgKey string, applicationKey string, version string, generatorKey string, codeForm CodeForm) CodePostByGeneratorKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version), html.EscapeString(generatorKey)) bodyDocument, err := json.Marshal(codeForm) if err != nil { return CodePostByGeneratorKeyResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return CodePostByGeneratorKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return CodePostByGeneratorKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return CodePostByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, Code: CodeFromJson(resp.Body)} case 409: return CodePostByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return CodePostByGeneratorKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DomainsPostResponse struct { StatusCode int Response *http.Response Error error Domain Domain ErrorS []Error } func DomainsPost(client Client, orgKey string, domain Domain) DomainsPostResponse { requestUrl := fmt.Sprintf("%s/domains/%s", client.BaseUrl, html.EscapeString(orgKey)) bodyDocument, err := json.Marshal(domain) if err != nil { return DomainsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return DomainsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DomainsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return DomainsPostResponse{StatusCode: resp.StatusCode, Response: resp, Domain: DomainFromJson(resp.Body)} case 409: return DomainsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return DomainsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type DomainsDeleteByNameResponse struct { StatusCode int Response *http.Response Error error } func DomainsDeleteByName(client Client, orgKey string, name string) DomainsDeleteByNameResponse { requestUrl := fmt.Sprintf("%s/domains/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(name)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return DomainsDeleteByNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return DomainsDeleteByNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return DomainsDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return DomainsDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return DomainsDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return DomainsDeleteByNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type EmailVerificationConfirmationFormsPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error } func EmailVerificationConfirmationFormsPost(client Client, emailVerificationConfirmationForm EmailVerificationConfirmationForm) EmailVerificationConfirmationFormsPostResponse { requestUrl := fmt.Sprintf("%s/email_verification_confirmations", client.BaseUrl) bodyDocument, err := json.Marshal(emailVerificationConfirmationForm) if err != nil { return EmailVerificationConfirmationFormsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return EmailVerificationConfirmationFormsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return EmailVerificationConfirmationFormsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return EmailVerificationConfirmationFormsPostResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return EmailVerificationConfirmationFormsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return EmailVerificationConfirmationFormsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorServicesGetParams struct { Guid string Uri string GeneratorKey string Limit int64 Offset int64 } type GeneratorServicesGetResponse struct { StatusCode int Response *http.Response Error error GeneratorServices []GeneratorService } func GeneratorServicesGet(client Client, params GeneratorServicesGetParams) GeneratorServicesGetResponse { requestUrl := fmt.Sprintf("%s/generator_services", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.Uri { urlValues.Add("uri", params.Uri) } if "" != params.GeneratorKey { urlValues.Add("generator_key", params.GeneratorKey) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(100, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return GeneratorServicesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorServicesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return GeneratorServicesGetResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorServices: func() []GeneratorService { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []GeneratorService for _, el := range tmp { all = append(all, GeneratorServiceFromMap(el)) } return all }()} default: return GeneratorServicesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorServicesGetByGuidResponse struct { StatusCode int Response *http.Response Error error GeneratorService GeneratorService } func GeneratorServicesGetByGuid(client Client, guid string) GeneratorServicesGetByGuidResponse { requestUrl := fmt.Sprintf("%s/generator_services/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return GeneratorServicesGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorServicesGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return GeneratorServicesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorService: GeneratorServiceFromJson(resp.Body)} case 404: return GeneratorServicesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return GeneratorServicesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorServicesPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error GeneratorService GeneratorService } func GeneratorServicesPost(client Client, generatorServiceForm GeneratorServiceForm) GeneratorServicesPostResponse { requestUrl := fmt.Sprintf("%s/generator_services", client.BaseUrl) bodyDocument, err := json.Marshal(generatorServiceForm) if err != nil { return GeneratorServicesPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return GeneratorServicesPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorServicesPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return GeneratorServicesPostResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorService: GeneratorServiceFromJson(resp.Body)} case 409: return GeneratorServicesPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return GeneratorServicesPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorServicesDeleteByGuidResponse struct { StatusCode int Response *http.Response Error error } func GeneratorServicesDeleteByGuid(client Client, guid string) GeneratorServicesDeleteByGuidResponse { requestUrl := fmt.Sprintf("%s/generator_services/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return GeneratorServicesDeleteByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorServicesDeleteByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return GeneratorServicesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return GeneratorServicesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return GeneratorServicesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return GeneratorServicesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorWithServicesGetParams struct { Guid string ServiceGuid string ServiceUri string AttributeName string Key string Limit int64 Offset int64 } type GeneratorWithServicesGetResponse struct { StatusCode int Response *http.Response Error error GeneratorWithServices []GeneratorWithService } func GeneratorWithServicesGet(client Client, params GeneratorWithServicesGetParams) GeneratorWithServicesGetResponse { requestUrl := fmt.Sprintf("%s/generators", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.ServiceGuid { urlValues.Add("service_guid", params.ServiceGuid) } if "" != params.ServiceUri { urlValues.Add("service_uri", params.ServiceUri) } if "" != params.AttributeName { urlValues.Add("attribute_name", params.AttributeName) } if "" != params.Key { urlValues.Add("key", params.Key) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(100, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return GeneratorWithServicesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorWithServicesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return GeneratorWithServicesGetResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorWithServices: func() []GeneratorWithService { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []GeneratorWithService for _, el := range tmp { all = append(all, GeneratorWithServiceFromMap(el)) } return all }()} default: return GeneratorWithServicesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type GeneratorWithServicesGetByKeyResponse struct { StatusCode int Response *http.Response Error error GeneratorWithService GeneratorWithService } func GeneratorWithServicesGetByKey(client Client, key string) GeneratorWithServicesGetByKeyResponse { requestUrl := fmt.Sprintf("%s/generators/%s", client.BaseUrl, html.EscapeString(key)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return GeneratorWithServicesGetByKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return GeneratorWithServicesGetByKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return GeneratorWithServicesGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorWithService: GeneratorWithServiceFromJson(resp.Body)} case 404: return GeneratorWithServicesGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return GeneratorWithServicesGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type HealthchecksGetHealthcheckResponse struct { StatusCode int Response *http.Response Error error GeneratorHealthcheck generator.Healthcheck } func HealthchecksGetHealthcheck(client Client) HealthchecksGetHealthcheckResponse { requestUrl := fmt.Sprintf("%s/_internal_/healthcheck", client.BaseUrl) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return HealthchecksGetHealthcheckResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return HealthchecksGetHealthcheckResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return HealthchecksGetHealthcheckResponse{StatusCode: resp.StatusCode, Response: resp, GeneratorHealthcheck: generator.HealthcheckFromJson(resp.Body)} default: return HealthchecksGetHealthcheckResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type HealthchecksGetMigrateResponse struct { StatusCode int Response *http.Response Error error Values map[string]string } func HealthchecksGetMigrate(client Client) HealthchecksGetMigrateResponse { requestUrl := fmt.Sprintf("%s/_internal_/migrate", client.BaseUrl) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return HealthchecksGetMigrateResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return HealthchecksGetMigrateResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return HealthchecksGetMigrateResponse{StatusCode: resp.StatusCode, Response: resp, Values: func() map[string]string { var tmp map[string]interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all map[string]string for key, el := range tmp { all[key] = el.(string) } return all }()} default: return HealthchecksGetMigrateResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ItemsGetParams struct { Q string Limit int64 Offset int64 } type ItemsGetResponse struct { StatusCode int Response *http.Response Error error Items []Item } func ItemsGet(client Client, params ItemsGetParams) ItemsGetResponse { requestUrl := fmt.Sprintf("%s/items", client.BaseUrl) urlValues := url.Values{} if "" != params.Q { urlValues.Add("q", params.Q) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ItemsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ItemsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ItemsGetResponse{StatusCode: resp.StatusCode, Response: resp, Items: func() []Item { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Item for _, el := range tmp { all = append(all, ItemFromMap(el)) } return all }()} default: return ItemsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ItemsGetByGuidResponse struct { StatusCode int Response *http.Response Error error Item Item } func ItemsGetByGuid(client Client, guid string) ItemsGetByGuidResponse { requestUrl := fmt.Sprintf("%s/items/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return ItemsGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ItemsGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ItemsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Item: ItemFromJson(resp.Body)} case 404: return ItemsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return ItemsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipsGetParams struct { OrgGuid string OrgKey string UserGuid string Role string Limit int64 Offset int64 } type MembershipsGetResponse struct { StatusCode int Response *http.Response Error error Memberships []Membership } func MembershipsGet(client Client, params MembershipsGetParams) MembershipsGetResponse { requestUrl := fmt.Sprintf("%s/memberships", client.BaseUrl) urlValues := url.Values{} if "" != params.OrgGuid { urlValues.Add("org_guid", params.OrgGuid) } if "" != params.OrgKey { urlValues.Add("org_key", params.OrgKey) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.Role { urlValues.Add("role", params.Role) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return MembershipsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return MembershipsGetResponse{StatusCode: resp.StatusCode, Response: resp, Memberships: func() []Membership { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Membership for _, el := range tmp { all = append(all, MembershipFromMap(el)) } return all }()} default: return MembershipsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipsGetByGuidResponse struct { StatusCode int Response *http.Response Error error Membership Membership } func MembershipsGetByGuid(client Client, guid string) MembershipsGetByGuidResponse { requestUrl := fmt.Sprintf("%s/memberships/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return MembershipsGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipsGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return MembershipsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Membership: MembershipFromJson(resp.Body)} case 404: return MembershipsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return MembershipsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipsDeleteByGuidResponse struct { StatusCode int Response *http.Response Error error } func MembershipsDeleteByGuid(client Client, guid string) MembershipsDeleteByGuidResponse { requestUrl := fmt.Sprintf("%s/memberships/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return MembershipsDeleteByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipsDeleteByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return MembershipsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return MembershipsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return MembershipsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return MembershipsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipRequestsGetParams struct { OrgGuid string OrgKey string UserGuid string Role string Limit int64 Offset int64 } type MembershipRequestsGetResponse struct { StatusCode int Response *http.Response Error error MembershipRequests []MembershipRequest } func MembershipRequestsGet(client Client, params MembershipRequestsGetParams) MembershipRequestsGetResponse { requestUrl := fmt.Sprintf("%s/membership_requests", client.BaseUrl) urlValues := url.Values{} if "" != params.OrgGuid { urlValues.Add("org_guid", params.OrgGuid) } if "" != params.OrgKey { urlValues.Add("org_key", params.OrgKey) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.Role { urlValues.Add("role", params.Role) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return MembershipRequestsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipRequestsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return MembershipRequestsGetResponse{StatusCode: resp.StatusCode, Response: resp, MembershipRequests: func() []MembershipRequest { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []MembershipRequest for _, el := range tmp { all = append(all, MembershipRequestFromMap(el)) } return all }()} default: return MembershipRequestsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipRequestsPostParams struct { OrgGuid string UserGuid string Role string } type MembershipRequestsPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error MembershipRequest MembershipRequest } func MembershipRequestsPost(client Client, params MembershipRequestsPostParams) MembershipRequestsPostResponse { requestUrl := fmt.Sprintf("%s/membership_requests", client.BaseUrl) urlValues := url.Values{} if "" != params.OrgGuid { urlValues.Add("org_guid", params.OrgGuid) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.Role { urlValues.Add("role", params.Role) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return MembershipRequestsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipRequestsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return MembershipRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp, MembershipRequest: MembershipRequestFromJson(resp.Body)} case 409: return MembershipRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return MembershipRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipRequestsPostAcceptByGuidResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error } func MembershipRequestsPostAcceptByGuid(client Client, guid string) MembershipRequestsPostAcceptByGuidResponse { requestUrl := fmt.Sprintf("%s/membership_requests/%s/accept", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "POST", requestUrl, ClientRequestBody{}) if err != nil { return MembershipRequestsPostAcceptByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipRequestsPostAcceptByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return MembershipRequestsPostAcceptByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return MembershipRequestsPostAcceptByGuidResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return MembershipRequestsPostAcceptByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type MembershipRequestsPostDeclineByGuidResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error } func MembershipRequestsPostDeclineByGuid(client Client, guid string) MembershipRequestsPostDeclineByGuidResponse { requestUrl := fmt.Sprintf("%s/membership_requests/%s/decline", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "POST", requestUrl, ClientRequestBody{}) if err != nil { return MembershipRequestsPostDeclineByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return MembershipRequestsPostDeclineByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return MembershipRequestsPostDeclineByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return MembershipRequestsPostDeclineByGuidResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return MembershipRequestsPostDeclineByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsGetParams struct { Guid string UserGuid string Key string Name string Namespace string Limit int64 Offset int64 } type OrganizationsGetResponse struct { StatusCode int Response *http.Response Error error Organizations []Organization } func OrganizationsGet(client Client, params OrganizationsGetParams) OrganizationsGetResponse { requestUrl := fmt.Sprintf("%s/organizations", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.Key { urlValues.Add("key", params.Key) } if "" != params.Name { urlValues.Add("name", params.Name) } if "" != params.Namespace { urlValues.Add("namespace", params.Namespace) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsGetResponse{StatusCode: resp.StatusCode, Response: resp, Organizations: func() []Organization { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Organization for _, el := range tmp { all = append(all, OrganizationFromMap(el)) } return all }()} default: return OrganizationsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsGetByKeyResponse struct { StatusCode int Response *http.Response Error error Organization Organization } func OrganizationsGetByKey(client Client, key string) OrganizationsGetByKeyResponse { requestUrl := fmt.Sprintf("%s/organizations/%s", client.BaseUrl, html.EscapeString(key)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsGetByKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsGetByKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Organization: OrganizationFromJson(resp.Body)} case 404: return OrganizationsGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return OrganizationsGetByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Organization Organization } func OrganizationsPost(client Client, organizationForm OrganizationForm) OrganizationsPostResponse { requestUrl := fmt.Sprintf("%s/organizations", client.BaseUrl) if "" == organizationForm.Visibility { organizationForm.Visibility = VisibilityFromString("organization") } bodyDocument, err := json.Marshal(organizationForm) if err != nil { return OrganizationsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return OrganizationsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Organization: OrganizationFromJson(resp.Body)} case 409: return OrganizationsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return OrganizationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsPutByKeyResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Organization Organization } func OrganizationsPutByKey(client Client, key string, organizationForm OrganizationForm) OrganizationsPutByKeyResponse { requestUrl := fmt.Sprintf("%s/organizations/%s", client.BaseUrl, html.EscapeString(key)) if "" == organizationForm.Visibility { organizationForm.Visibility = VisibilityFromString("organization") } bodyDocument, err := json.Marshal(organizationForm) if err != nil { return OrganizationsPutByKeyResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return OrganizationsPutByKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsPutByKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsPutByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Organization: OrganizationFromJson(resp.Body)} case 409: return OrganizationsPutByKeyResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return OrganizationsPutByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsDeleteByKeyResponse struct { StatusCode int Response *http.Response Error error } func OrganizationsDeleteByKey(client Client, key string) OrganizationsDeleteByKeyResponse { requestUrl := fmt.Sprintf("%s/organizations/%s", client.BaseUrl, html.EscapeString(key)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsDeleteByKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsDeleteByKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return OrganizationsDeleteByKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return OrganizationsDeleteByKeyResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return OrganizationsDeleteByKeyResponse{StatusCode: resp.StatusCode, Response: resp} default: return OrganizationsDeleteByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsGetAttributesByKeyParams struct { Name string Limit int64 Offset int64 } type OrganizationsGetAttributesByKeyResponse struct { StatusCode int Response *http.Response Error error AttributeValues []AttributeValue } func OrganizationsGetAttributesByKey(client Client, key string, params OrganizationsGetAttributesByKeyParams) OrganizationsGetAttributesByKeyResponse { requestUrl := fmt.Sprintf("%s/organizations/%s/attributes", client.BaseUrl, html.EscapeString(key)) urlValues := url.Values{} if "" != params.Name { urlValues.Add("name", params.Name) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsGetAttributesByKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsGetAttributesByKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsGetAttributesByKeyResponse{StatusCode: resp.StatusCode, Response: resp, AttributeValues: func() []AttributeValue { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []AttributeValue for _, el := range tmp { all = append(all, AttributeValueFromMap(el)) } return all }()} default: return OrganizationsGetAttributesByKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsGetAttributesByKeyAndNameResponse struct { StatusCode int Response *http.Response Error error AttributeValue AttributeValue } func OrganizationsGetAttributesByKeyAndName(client Client, key string, name string) OrganizationsGetAttributesByKeyAndNameResponse { requestUrl := fmt.Sprintf("%s/organizations/%s/attributes/%s", client.BaseUrl, html.EscapeString(key), html.EscapeString(name)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsGetAttributesByKeyAndNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsGetAttributesByKeyAndNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsGetAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, AttributeValue: AttributeValueFromJson(resp.Body)} case 404: return OrganizationsGetAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return OrganizationsGetAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsPutAttributesByKeyAndNameResponse struct { StatusCode int Response *http.Response Error error AttributeValue AttributeValue ErrorS []Error } func OrganizationsPutAttributesByKeyAndName(client Client, key string, name string, attributeValueForm AttributeValueForm) OrganizationsPutAttributesByKeyAndNameResponse { requestUrl := fmt.Sprintf("%s/organizations/%s/attributes/%s", client.BaseUrl, html.EscapeString(key), html.EscapeString(name)) bodyDocument, err := json.Marshal(attributeValueForm) if err != nil { return OrganizationsPutAttributesByKeyAndNameResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return OrganizationsPutAttributesByKeyAndNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsPutAttributesByKeyAndNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return OrganizationsPutAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, AttributeValue: AttributeValueFromJson(resp.Body)} case 201: return OrganizationsPutAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, AttributeValue: AttributeValueFromJson(resp.Body)} case 404: return OrganizationsPutAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return OrganizationsPutAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return OrganizationsPutAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type OrganizationsDeleteAttributesByKeyAndNameResponse struct { StatusCode int Response *http.Response Error error } func OrganizationsDeleteAttributesByKeyAndName(client Client, key string, name string) OrganizationsDeleteAttributesByKeyAndNameResponse { requestUrl := fmt.Sprintf("%s/organizations/%s/attributes/%s", client.BaseUrl, html.EscapeString(key), html.EscapeString(name)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return OrganizationsDeleteAttributesByKeyAndNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return OrganizationsDeleteAttributesByKeyAndNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return OrganizationsDeleteAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return OrganizationsDeleteAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return OrganizationsDeleteAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return OrganizationsDeleteAttributesByKeyAndNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PasswordResetsPostResponse struct { StatusCode int Response *http.Response Error error Authentication Authentication ErrorS []Error } func PasswordResetsPost(client Client, passwordReset PasswordReset) PasswordResetsPostResponse { requestUrl := fmt.Sprintf("%s/password_resets", client.BaseUrl) bodyDocument, err := json.Marshal(passwordReset) if err != nil { return PasswordResetsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return PasswordResetsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PasswordResetsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return PasswordResetsPostResponse{StatusCode: resp.StatusCode, Response: resp, Authentication: AuthenticationFromJson(resp.Body)} case 409: return PasswordResetsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return PasswordResetsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type PasswordResetRequestsPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error } func PasswordResetRequestsPost(client Client, passwordResetRequest PasswordResetRequest) PasswordResetRequestsPostResponse { requestUrl := fmt.Sprintf("%s/password_reset_requests", client.BaseUrl) bodyDocument, err := json.Marshal(passwordResetRequest) if err != nil { return PasswordResetRequestsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return PasswordResetRequestsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return PasswordResetRequestsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return PasswordResetRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp} case 409: return PasswordResetRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return PasswordResetRequestsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type SubscriptionsGetParams struct { Guid string OrganizationKey string UserGuid string Publication Publication Limit int64 Offset int64 } type SubscriptionsGetResponse struct { StatusCode int Response *http.Response Error error Subscriptions []Subscription } func SubscriptionsGet(client Client, params SubscriptionsGetParams) SubscriptionsGetResponse { requestUrl := fmt.Sprintf("%s/subscriptions", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.OrganizationKey { urlValues.Add("organization_key", params.OrganizationKey) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.Publication { urlValues.Add("publication", string(params.Publication)) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return SubscriptionsGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return SubscriptionsGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return SubscriptionsGetResponse{StatusCode: resp.StatusCode, Response: resp, Subscriptions: func() []Subscription { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Subscription for _, el := range tmp { all = append(all, SubscriptionFromMap(el)) } return all }()} default: return SubscriptionsGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type SubscriptionsGetByGuidResponse struct { StatusCode int Response *http.Response Error error Subscription Subscription } func SubscriptionsGetByGuid(client Client, guid string) SubscriptionsGetByGuidResponse { requestUrl := fmt.Sprintf("%s/subscriptions/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return SubscriptionsGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return SubscriptionsGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return SubscriptionsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Subscription: SubscriptionFromJson(resp.Body)} case 404: return SubscriptionsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return SubscriptionsGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type SubscriptionsPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Subscription Subscription } func SubscriptionsPost(client Client, subscriptionForm SubscriptionForm) SubscriptionsPostResponse { requestUrl := fmt.Sprintf("%s/subscriptions", client.BaseUrl) bodyDocument, err := json.Marshal(subscriptionForm) if err != nil { return SubscriptionsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return SubscriptionsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return SubscriptionsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 201: return SubscriptionsPostResponse{StatusCode: resp.StatusCode, Response: resp, Subscription: SubscriptionFromJson(resp.Body)} case 409: return SubscriptionsPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return SubscriptionsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type SubscriptionsDeleteByGuidResponse struct { StatusCode int Response *http.Response Error error } func SubscriptionsDeleteByGuid(client Client, guid string) SubscriptionsDeleteByGuidResponse { requestUrl := fmt.Sprintf("%s/subscriptions/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return SubscriptionsDeleteByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return SubscriptionsDeleteByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return SubscriptionsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return SubscriptionsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return SubscriptionsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return SubscriptionsDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TokensGetUsersByUserGuidParams struct { Guid string Limit int64 Offset int64 } type TokensGetUsersByUserGuidResponse struct { StatusCode int Response *http.Response Error error Tokens []Token } func TokensGetUsersByUserGuid(client Client, userGuid string, params TokensGetUsersByUserGuidParams) TokensGetUsersByUserGuidResponse { requestUrl := fmt.Sprintf("%s/tokens/users/%s", client.BaseUrl, html.EscapeString(userGuid)) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return TokensGetUsersByUserGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TokensGetUsersByUserGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TokensGetUsersByUserGuidResponse{StatusCode: resp.StatusCode, Response: resp, Tokens: func() []Token { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Token for _, el := range tmp { all = append(all, TokenFromMap(el)) } return all }()} default: return TokensGetUsersByUserGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TokensGetCleartextByGuidResponse struct { StatusCode int Response *http.Response Error error CleartextToken CleartextToken } func TokensGetCleartextByGuid(client Client, guid string) TokensGetCleartextByGuidResponse { requestUrl := fmt.Sprintf("%s/tokens/%s/cleartext", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return TokensGetCleartextByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TokensGetCleartextByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return TokensGetCleartextByGuidResponse{StatusCode: resp.StatusCode, Response: resp, CleartextToken: CleartextTokenFromJson(resp.Body)} case 404: return TokensGetCleartextByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return TokensGetCleartextByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TokensPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Token Token } func TokensPost(client Client, tokenForm TokenForm) TokensPostResponse { requestUrl := fmt.Sprintf("%s/tokens", client.BaseUrl) bodyDocument, err := json.Marshal(tokenForm) if err != nil { return TokensPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return TokensPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TokensPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 201: return TokensPostResponse{StatusCode: resp.StatusCode, Response: resp, Token: TokenFromJson(resp.Body)} case 409: return TokensPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return TokensPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type TokensDeleteByGuidResponse struct { StatusCode int Response *http.Response Error error } func TokensDeleteByGuid(client Client, guid string) TokensDeleteByGuidResponse { requestUrl := fmt.Sprintf("%s/tokens/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return TokensDeleteByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return TokensDeleteByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return TokensDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return TokensDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return TokensDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return TokensDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersGetParams struct { Guid string Email string Nickname string Token string } type UsersGetResponse struct { StatusCode int Response *http.Response Error error Users []User } func UsersGet(client Client, params UsersGetParams) UsersGetResponse { requestUrl := fmt.Sprintf("%s/users", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.Email { urlValues.Add("email", params.Email) } if "" != params.Nickname { urlValues.Add("nickname", params.Nickname) } if "" != params.Token { urlValues.Add("token", params.Token) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return UsersGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersGetResponse{StatusCode: resp.StatusCode, Response: resp, Users: func() []User { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []User for _, el := range tmp { all = append(all, UserFromMap(el)) } return all }()} default: return UsersGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersGetByGuidResponse struct { StatusCode int Response *http.Response Error error User User } func UsersGetByGuid(client Client, guid string) UsersGetByGuidResponse { requestUrl := fmt.Sprintf("%s/users/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return UsersGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, User: UserFromJson(resp.Body)} case 404: return UsersGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return UsersGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersPostAuthenticateParams struct { Email string Password string } type UsersPostAuthenticateResponse struct { StatusCode int Response *http.Response Error error Authentication Authentication ErrorS []Error } func UsersPostAuthenticate(client Client, params UsersPostAuthenticateParams) UsersPostAuthenticateResponse { requestUrl := fmt.Sprintf("%s/users/authenticate", client.BaseUrl) urlValues := url.Values{} if "" != params.Email { urlValues.Add("email", params.Email) } if "" != params.Password { urlValues.Add("password", params.Password) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return UsersPostAuthenticateResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersPostAuthenticateResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersPostAuthenticateResponse{StatusCode: resp.StatusCode, Response: resp, Authentication: AuthenticationFromJson(resp.Body)} case 409: return UsersPostAuthenticateResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return UsersPostAuthenticateResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersPostAuthenticateGithubParams struct { Token string } type UsersPostAuthenticateGithubResponse struct { StatusCode int Response *http.Response Error error Authentication Authentication ErrorS []Error } func UsersPostAuthenticateGithub(client Client, params UsersPostAuthenticateGithubParams) UsersPostAuthenticateGithubResponse { requestUrl := fmt.Sprintf("%s/users/authenticate_github", client.BaseUrl) urlValues := url.Values{} if "" != params.Token { urlValues.Add("token", params.Token) } body := ClientRequestBody{contentType: "application/x-www-form-urlencoded", bytes: strings.NewReader(urlValues.Encode())} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return UsersPostAuthenticateGithubResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersPostAuthenticateGithubResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersPostAuthenticateGithubResponse{StatusCode: resp.StatusCode, Response: resp, Authentication: AuthenticationFromJson(resp.Body)} case 409: return UsersPostAuthenticateGithubResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return UsersPostAuthenticateGithubResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error User User } func UsersPost(client Client, userForm UserForm) UsersPostResponse { requestUrl := fmt.Sprintf("%s/users", client.BaseUrl) bodyDocument, err := json.Marshal(userForm) if err != nil { return UsersPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return UsersPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersPostResponse{StatusCode: resp.StatusCode, Response: resp, User: UserFromJson(resp.Body)} case 409: return UsersPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return UsersPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type UsersPutByGuidResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error User User } func UsersPutByGuid(client Client, guid string, userUpdateForm UserUpdateForm) UsersPutByGuidResponse { requestUrl := fmt.Sprintf("%s/users/%s", client.BaseUrl, html.EscapeString(guid)) bodyDocument, err := json.Marshal(userUpdateForm) if err != nil { return UsersPutByGuidResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return UsersPutByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return UsersPutByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return UsersPutByGuidResponse{StatusCode: resp.StatusCode, Response: resp, User: UserFromJson(resp.Body)} case 409: return UsersPutByGuidResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return UsersPutByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type ValidationsPostResponse struct { StatusCode int Response *http.Response Error error Validation Validation } func ValidationsPost(client Client, string_ string) ValidationsPostResponse { requestUrl := fmt.Sprintf("%s/validations", client.BaseUrl) bodyDocument, err := json.Marshal(string_) if err != nil { return ValidationsPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return ValidationsPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return ValidationsPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return ValidationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Validation: ValidationFromJson(resp.Body)} default: return ValidationsPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsGetByApplicationKeyParams struct { Limit int64 Offset int64 } type VersionsGetByApplicationKeyResponse struct { StatusCode int Response *http.Response Error error Versions []Version } func VersionsGetByApplicationKey(client Client, orgKey string, applicationKey string, params VersionsGetByApplicationKeyParams) VersionsGetByApplicationKeyResponse { requestUrl := fmt.Sprintf("%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey)) urlValues := url.Values{} if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return VersionsGetByApplicationKeyResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsGetByApplicationKeyResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return VersionsGetByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Versions: func() []Version { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Version for _, el := range tmp { all = append(all, VersionFromMap(el)) } return all }()} default: return VersionsGetByApplicationKeyResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsGetByApplicationKeyAndVersionResponse struct { StatusCode int Response *http.Response Error error Version Version } func VersionsGetByApplicationKeyAndVersion(client Client, orgKey string, applicationKey string, version string) VersionsGetByApplicationKeyAndVersionResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return VersionsGetByApplicationKeyAndVersionResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsGetByApplicationKeyAndVersionResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return VersionsGetByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, Version: VersionFromJson(resp.Body)} case 404: return VersionsGetByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp} default: return VersionsGetByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsPostByVersionResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Version Version } func VersionsPostByVersion(client Client, orgKey string, version string, versionForm VersionForm) VersionsPostByVersionResponse { requestUrl := fmt.Sprintf("%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(version)) bodyDocument, err := json.Marshal(versionForm) if err != nil { return VersionsPostByVersionResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return VersionsPostByVersionResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsPostByVersionResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return VersionsPostByVersionResponse{StatusCode: resp.StatusCode, Response: resp, Version: VersionFromJson(resp.Body)} case 409: return VersionsPostByVersionResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return VersionsPostByVersionResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsPutByApplicationKeyAndVersionResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Version Version } func VersionsPutByApplicationKeyAndVersion(client Client, orgKey string, applicationKey string, version string, versionForm VersionForm) VersionsPutByApplicationKeyAndVersionResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version)) bodyDocument, err := json.Marshal(versionForm) if err != nil { return VersionsPutByApplicationKeyAndVersionResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "PUT", requestUrl, body) if err != nil { return VersionsPutByApplicationKeyAndVersionResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsPutByApplicationKeyAndVersionResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return VersionsPutByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, Version: VersionFromJson(resp.Body)} case 409: return VersionsPutByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return VersionsPutByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsDeleteByApplicationKeyAndVersionResponse struct { StatusCode int Response *http.Response Error error } func VersionsDeleteByApplicationKeyAndVersion(client Client, orgKey string, applicationKey string, version string) VersionsDeleteByApplicationKeyAndVersionResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return VersionsDeleteByApplicationKeyAndVersionResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsDeleteByApplicationKeyAndVersionResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return VersionsDeleteByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return VersionsDeleteByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return VersionsDeleteByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp} default: return VersionsDeleteByApplicationKeyAndVersionResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type VersionsGetExampleByApplicationKeyAndVersionAndTypeNameParams struct { SubTypeName string OptionalFields string } type VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse struct { StatusCode int Response *http.Response Error error Value map[string]interface{} } func VersionsGetExampleByApplicationKeyAndVersionAndTypeName(client Client, orgKey string, applicationKey string, version string, typeName string, params VersionsGetExampleByApplicationKeyAndVersionAndTypeNameParams) VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse { requestUrl := fmt.Sprintf("%s/%s/%s/%s/example/%s", client.BaseUrl, html.EscapeString(orgKey), html.EscapeString(applicationKey), html.EscapeString(version), html.EscapeString(typeName)) urlValues := url.Values{} if "" != params.SubTypeName { urlValues.Add("sub_type_name", params.SubTypeName) } if "" != params.OptionalFields { urlValues.Add("optional_fields", params.OptionalFields) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse{StatusCode: resp.StatusCode, Response: resp, Value: var tmp map[string]interface{} json.NewDecoder(resp.Body).Decode(&tmp) tmp} case 404: return VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse{StatusCode: resp.StatusCode, Response: resp} default: return VersionsGetExampleByApplicationKeyAndVersionAndTypeNameResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WatchesGetParams struct { Guid string UserGuid string OrganizationKey string ApplicationKey string Limit int64 Offset int64 } type WatchesGetResponse struct { StatusCode int Response *http.Response Error error Watches []Watch } func WatchesGet(client Client, params WatchesGetParams) WatchesGetResponse { requestUrl := fmt.Sprintf("%s/watches", client.BaseUrl) urlValues := url.Values{} if "" != params.Guid { urlValues.Add("guid", params.Guid) } if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.OrganizationKey { urlValues.Add("organization_key", params.OrganizationKey) } if "" != params.ApplicationKey { urlValues.Add("application_key", params.ApplicationKey) } if 0 == params.Limit { urlValues.Add("limit", strconv.FormatInt(25, 10)) } else { urlValues.Add("limit", strconv.FormatInt(params.Limit, 10)) } if 0 == params.Offset { urlValues.Add("offset", strconv.FormatInt(0, 10)) } else { urlValues.Add("offset", strconv.FormatInt(params.Offset, 10)) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WatchesGetResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WatchesGetResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WatchesGetResponse{StatusCode: resp.StatusCode, Response: resp, Watches: func() []Watch { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Watch for _, el := range tmp { all = append(all, WatchFromMap(el)) } return all }()} default: return WatchesGetResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WatchesGetByGuidResponse struct { StatusCode int Response *http.Response Error error Watch Watch } func WatchesGetByGuid(client Client, guid string) WatchesGetByGuidResponse { requestUrl := fmt.Sprintf("%s/watches/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WatchesGetByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WatchesGetByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WatchesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Watch: WatchFromJson(resp.Body)} case 404: return WatchesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return WatchesGetByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WatchesGetCheckParams struct { UserGuid string OrganizationKey string ApplicationKey string } type WatchesGetCheckResponse struct { StatusCode int Response *http.Response Error error Value string } func WatchesGetCheck(client Client, params WatchesGetCheckParams) WatchesGetCheckResponse { requestUrl := fmt.Sprintf("%s/watches/check", client.BaseUrl) urlValues := url.Values{} if "" != params.UserGuid { urlValues.Add("user_guid", params.UserGuid) } if "" != params.OrganizationKey { urlValues.Add("organization_key", params.OrganizationKey) } if "" != params.ApplicationKey { urlValues.Add("application_key", params.ApplicationKey) } encodedValues := urlValues.Encode() if encodedValues != "" { requestUrl += "?" + encodedValues } request, err := buildRequest(client, "GET", requestUrl, ClientRequestBody{}) if err != nil { return WatchesGetCheckResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WatchesGetCheckResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 200: return WatchesGetCheckResponse{StatusCode: resp.StatusCode, Response: resp, Value: string(resp.Body)} default: return WatchesGetCheckResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WatchesPostResponse struct { StatusCode int Response *http.Response Error error ErrorS []Error Watch Watch } func WatchesPost(client Client, watchForm WatchForm) WatchesPostResponse { requestUrl := fmt.Sprintf("%s/watches", client.BaseUrl) bodyDocument, err := json.Marshal(watchForm) if err != nil { return WatchesPostResponse{Error: err} } body := ClientRequestBody{contentType: "application/json", bytes: bytes.NewReader(bodyDocument)} request, err := buildRequest(client, "POST", requestUrl, body) if err != nil { return WatchesPostResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WatchesPostResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 201: return WatchesPostResponse{StatusCode: resp.StatusCode, Response: resp, Watch: WatchFromJson(resp.Body)} case 409: return WatchesPostResponse{StatusCode: resp.StatusCode, Response: resp, ErrorS: func() []Error { var tmp []interface{} json.NewDecoder(resp.Body).Decode(&tmp) var all []Error for _, el := range tmp { all = append(all, ErrorFromMap(el)) } return all }()} default: return WatchesPostResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } type WatchesDeleteByGuidResponse struct { StatusCode int Response *http.Response Error error } func WatchesDeleteByGuid(client Client, guid string) WatchesDeleteByGuidResponse { requestUrl := fmt.Sprintf("%s/watches/%s", client.BaseUrl, html.EscapeString(guid)) request, err := buildRequest(client, "DELETE", requestUrl, ClientRequestBody{}) if err != nil { return WatchesDeleteByGuidResponse{Error: err} } resp, err := client.HttpClient.Do(request) if err != nil { return WatchesDeleteByGuidResponse{Error: err} } defer resp.Body.Close() switch resp.StatusCode { case 204: return WatchesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 401: return WatchesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} case 404: return WatchesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp} default: return WatchesDeleteByGuidResponse{StatusCode: resp.StatusCode, Response: resp, Error: errors.New(resp.Status)} } } func buildRequest(client Client, method, urlStr string, body ClientRequestBody) (*http.Request, error) { request, err := http.NewRequest(method, urlStr, body.bytes) if err != nil { return nil, err } request.Header.Add("User-Agent", UserAgent) request.Header.Add("X-Apidoc-Version", Version) request.Header.Add("X-Apidoc-Version-Major", strconv.Itoa(VersionMajor)) if client.Headers != nil { for key, values := range client.Headers { for _, value := range values { request.Header.Add(key, value) } } } if body.contentType != "" { request.Header.Add("Content-Type", body.contentType) } if client.Username != "" { request.SetBasicAuth(client.Username, client.Password) } return request, nil }